<% layout('/layouts/default.html', {title: '模板分类管理', libs: ['validate','ueditor','fileupload']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text(ocrTempateCategory.isNewRecord ? '新增模板分类' : '编辑模板分类')}
			</div>
			<div class="box-tools pull-right hide">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${ocrTempateCategory}" action="${ctx}/ocr/ocrTempateCategory/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4">${text('上级模板分类')}：</label>
							<div class="col-sm-8">
								<#form:treeselect id="parent" title="${text('上级模板分类')}"
									path="parent.id" labelPath="parent.tempateCategoryName"
									url="${ctx}/ocr/ocrTempateCategory/treeData?excludeCode=${ocrTempateCategory.id}"
									class="" allowClear="true" canSelectRoot="true" canSelectParent="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('编码')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:hidden path="isNewRecord"/>
								<#form:input path="tempateCategoryCode" maxlength="64" readonly="${!ocrTempateCategory.isNewRecord}" class="form-control required abc"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('排序号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="treeSort" maxlength="8" class="form-control required digits"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="tempateCategoryName" maxlength="200" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('标签')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								
								<#form:listselect  title="标签选择"
									path="categoryTagNames" labelPath="categoryLabelTageName"
									url="${ctx}/ocr/ocrTags/ocrTagsSelect" allowClear="true" 
									checkbox="true" itemCode="tagName" itemName="tagName"/>								
								
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('描述')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="description" rows="4" maxlength="500" class="form-control"/>
							</div>
						</div>
					</div>
				<#form:hidden path="trainDataSet"/>
				<#form:hidden path="trainModeSet"/>
				<#form:hidden path="trainPromptSet"/>
				<#form:hidden path="trainInferSet"/>
				<#form:hidden path="remarks"/>
		
				
				</div>
				
				<div class="form-unit">${text('政策信息')}</div>				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('规则详情')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:ueditor path="trainContent" maxlength="10000" height="200" class="required"
										simpleToolbars="true" readonly="false" outline="false"/>											
							</div>
						</div>
					</div>
				</div>
				<div class="form-unit">${text('模型与数据集')}</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">
								<span class="required hide">*</span> ${text('训练数据集')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="ocrTempateCategory_train_data_set" bizKey="${ocrTempateCategory.id}" bizType="ocrTempateCategory_train_data_set"
									uploadType="image" maxUploadNum="2000" class="" readonly="false" preview="true" dataMap="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">
								<span class="required hide">*</span> ${text('训练模型集')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="ocrTempateCategory_train_mode_set" bizKey="${ocrTempateCategory.id}" bizType="ocrTempateCategory_train_mode_set"
									uploadType="file" maxUploadNum="20"  class="" readonly="false" preview="true" dataMap="true"/>
							</div>
						</div>
					</div>
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">
								<span class="required hide">*</span> ${text('训练推理集')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="ocrTempateCategory_train_infer_set" bizKey="${ocrTempateCategory.id}" bizType="ocrTempateCategory_train_infer_set"
									uploadType="file" maxUploadNum="20"  class="" readonly="false" preview="true" dataMap="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">
								<span class="required hide">*</span> ${text('训练提示词集')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="ocrTempateCategory_train_prompt_set" bizKey="${ocrTempateCategory.id}" bizType="ocrTempateCategory_train_prompt_set"
									uploadType="file"  maxUploadNum="20"  class="" readonly="false" preview="true" dataMap="true"/>
							</div>
						</div>
					</div>
				</div>				
				
				
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('ocr:ocrTempateCategory:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					(contentWindow.win||contentWindow).$('#dataGrid').dataGrid('refreshTreeChildren',
							$('#parentCode').val(), '${ocrTempateCategory.id}');
				});
			}
		}, "json");
    }
});

// 选择上级节点回调方法
function treeselectCallback(id, act, index, layero){
	if (id == 'parent' && (act == 'ok' || act == 'clear')){
		// 创建并初始化下一个节点信息，如：排序号、默认值
		$.get('${ctx}/ocr/ocrTempateCategory/createNextNode?parentCode='
				+$('#parentCode').val(), function(data){
			$('#treeSort').val(data.treeSort);
		});
	}
}
</script>